home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / app / plug_in.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-02-13  |  6.4 KB  |  197 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. #ifndef __PLUG_IN_H__
  20. #define __PLUG_IN_H__
  21.  
  22.  
  23. #include "procedural_db.h"
  24. #include "gimpprogress.h"
  25. #include "drawable.h"
  26.  
  27.  
  28. #define WRITE_BUFFER_SIZE  512
  29.  
  30. #define PLUG_IN_RGB_IMAGE       0x01
  31. #define PLUG_IN_GRAY_IMAGE      0x02
  32. #define PLUG_IN_INDEXED_IMAGE   0x04
  33. #define PLUG_IN_RGBA_IMAGE      0x08
  34. #define PLUG_IN_GRAYA_IMAGE     0x10
  35. #define PLUG_IN_INDEXEDA_IMAGE  0x20
  36.  
  37.  
  38. typedef enum
  39. {
  40.   RUN_INTERACTIVE    = 0,
  41.   RUN_NONINTERACTIVE = 1,
  42.   RUN_WITH_LAST_VALS = 2
  43. } RunModeType;
  44.  
  45.  
  46. struct _PlugIn
  47. {
  48.   guint         open : 1;         /* Is the plug-in open* */
  49.   guint         destroy : 1;      /* Should the plug-in by destroyed* */
  50.   guint         query : 1;        /* Are we querying the plug-in? */
  51. #ifdef HACK_FOR_BUG_66859
  52.   guint        init : 1;      /* Are we initing the plug-in? */
  53. #endif
  54.   guint         synchronous : 1;  /* Is the plug-in running synchronously? */
  55.   guint         recurse : 1;      /* Have we called 'gtk_main' recursively? */
  56.   guint         busy : 1;         /* Is the plug-in busy with a temp proc? */
  57.   pid_t         pid;              /* Plug-ins process id */
  58.   gchar        *args[7];          /* Plug-ins command line arguments */
  59.  
  60.   GIOChannel   *my_read;          /* App's read and write channels */
  61.   GIOChannel   *my_write;
  62.   GIOChannel   *his_read;         /* Plug-in's read and write channels */
  63.   GIOChannel   *his_write;
  64.  
  65.   guint32       input_id;         /* Id of input proc */
  66.  
  67.   gchar         write_buffer[WRITE_BUFFER_SIZE]; /* Buffer for writing */
  68.   gint          write_buffer_index;              /* Buffer index for writing */
  69.  
  70.   GSList       *temp_proc_defs;   /* Temporary procedures  */
  71.  
  72.   gimp_progress *progress;        /* Progress dialog */
  73.  
  74.   gpointer      user_data;        /* Handle for hanging data onto */
  75. };
  76.  
  77. struct _PlugInDef
  78. {
  79.   gchar    *prog;
  80.   GSList   *proc_defs;
  81.   gchar    *locale_domain;
  82.   gchar    *locale_path;
  83.   gchar    *help_path;
  84.   time_t    mtime;
  85.   gboolean  query;
  86. #ifdef HACK_FOR_BUG_66859
  87.   gboolean  init;
  88. #endif
  89. };
  90.  
  91. struct _PlugInProcDef
  92. {
  93.   gchar      *prog;
  94.   gchar      *menu_path;
  95.   gchar      *accelerator;
  96.   gchar      *extensions;
  97.   gchar      *prefixes;
  98.   gchar      *magics;
  99.   gchar      *image_types;
  100.   gint        image_types_val;
  101.   ProcRecord  db_info;
  102.   GSList     *extensions_list;
  103.   GSList     *prefixes_list;
  104.   GSList     *magics_list;
  105.   time_t      mtime;
  106. };
  107.  
  108.  
  109. /* Initialize the plug-ins */
  110. void            plug_in_init                 (void);
  111.  
  112. /* Kill all running plug-ins */
  113. void            plug_in_kill                 (void);
  114.  
  115. /*  Add a plug-in to the list of valid plug-ins and query the plug-in
  116.  *  for information if necessary.
  117.  */
  118. void            plug_in_add                  (gchar         *name,
  119.                           gchar         *menu_path,
  120.                           gchar         *accelerator);
  121.  
  122. /* Get the "image_types" the plug-in works on. */
  123. gchar         * plug_in_image_types          (gchar         *name);
  124.  
  125. /* Add in the file load/save handler fields procedure. */
  126. PlugInProcDef * plug_in_file_handler         (gchar         *name,
  127.                           gchar         *extensions,
  128.                           gchar         *prefixes,
  129.                           gchar         *magics);
  130.  
  131. /* Add a plug-in definition. */
  132. void            plug_in_def_add              (PlugInDef     *plug_in_def);
  133.  
  134. /* Allocate and free a plug-in definition. */
  135. PlugInDef     * plug_in_def_new              (gchar         *prog);
  136. void            plug_in_def_free             (PlugInDef     *plug_in_def, 
  137.                           gboolean       free_proc_defs);
  138.  
  139. /* Retrieve a plug-ins menu path */
  140. gchar         * plug_in_menu_path            (gchar         *name);
  141.  
  142. /* Retrieve a plug-ins help path */
  143. gchar         * plug_in_help_path            (gchar         *prog_name);
  144.  
  145. /* Create a new plug-in structure */
  146. PlugIn        * plug_in_new                  (gchar         *name);
  147.  
  148. /*  Destroy a plug-in structure.
  149.  *  This will close the plug-in first if necessary.
  150.  */
  151. void            plug_in_destroy              (PlugIn        *plug_in);
  152.  
  153. /* Open a plug-in. This cause the plug-in to run.
  154.  * If returns TRUE, you must destroy the plugin.
  155.  * If returns FALSE, you must not destroy the plugin.
  156.  */
  157. gboolean        plug_in_open                 (PlugIn        *plug_in);
  158.  
  159. /* Close a plug-in. This kills the plug-in and releases its resources. */
  160. void            plug_in_close                (PlugIn        *plug_in,
  161.                           gboolean       kill_it);
  162.  
  163. /* Run a plug-in as if it were a procedure database procedure */
  164. Argument      * plug_in_run                  (ProcRecord    *proc_rec,
  165.                           Argument      *args,
  166.                           gint           argc,
  167.                           gboolean       synchronous,
  168.                           gboolean       destroy_values,
  169.                           gint           gdisp_ID);
  170.  
  171. /*  Run the last plug-in again with the same arguments. Extensions
  172.  *  are exempt from this "privelege".
  173.  */
  174. void            plug_in_repeat               (gboolean       with_interface);
  175.  
  176. /* Set the sensitivity for plug-in menu items based on the image type. */
  177. void            plug_in_set_menu_sensitivity (GimpImageType  type);
  178.  
  179. /* Register an internal plug-in.  This is for file load-save
  180.  * handlers, which are organized around the plug-in data structure.
  181.  * This could all be done a little better, but oh well.  -josh
  182.  */
  183. void            plug_in_add_internal         (PlugInProcDef *proc_def);
  184. GSList        * plug_in_extensions_parse     (gchar         *extensions);
  185. gint            plug_in_image_types_parse    (gchar         *image_types);
  186.  
  187. void            plug_in_progress_init        (PlugIn        *plug_in,
  188.                           gchar         *message,
  189.                           gint           gdisp_ID);
  190. void            plug_in_progress_update      (PlugIn        *plug_in,
  191.                           gdouble        percentage);
  192.  
  193. extern PlugIn *current_plug_in;
  194. extern GSList *proc_defs;
  195.  
  196. #endif /* __PLUG_IN_H__ */
  197.